import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

///  自定义 键盘 按钮
class CustomKbBtn extends StatefulWidget {
  ///  按钮显示的文本内容
   String text;

  CustomKbBtn({required this.text, this.callback});
  ///  按钮 点击事件的回调函数
  final callback;
  @override
  State<StatefulWidget> createState() {
    return ButtonState();
  }
}

class ButtonState extends State<CustomKbBtn> {
  ///回调函数执行体
  var backMethod;

  void back() {
    widget.callback('$backMethod');
  }

  @override
  Widget build(BuildContext context) {

    /// 获取当前屏幕的总宽度，从而得出单个按钮的宽度
    MediaQueryData mediaQuery = MediaQuery.of(context);
    var _screenWidth = mediaQuery.size.width;

    return InkWell(
      onTap: back,
      child: new Container(
          height:50.0,
          width: (_screenWidth - 6 * 4) / 3,
          margin: EdgeInsets.only(right: 6, bottom: 6),
          alignment: Alignment.center,
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(8),
          ),
          child: widget.text == '删除'
              ? Image.asset(
            'images/icon_keyboard_delete.png',
            width: 32.w,
            height: 22.w,
          )
          : Text(
            widget.text,
            style: new TextStyle(color: Color(0xff323232), fontSize: 26.sp),
          )
         ),
    );
  }
}